package com.test.daily.leetcode.y2021.m10.day1020;

/**
 * @descriptions: MinMove
 * @author: Tom
 * @date: 2021/10/20 下午 01:41
 * @version: 1.0
 */
public class Code01_MinMove {
    public static void main(String[] args) {
        Code01_MinMove cm = new Code01_MinMove();
        int[] nums = new int[]{1,1,1};
        System.out.println(cm.minMoves(nums));
    }
    public int minMoves(int[] nums) {
        int ans = 0;
//        Arrays.sort(nums);
//        for(int i = 0; i < nums.length; i++){
//            ans += (nums[i]-nums[0]);
//        }
        int min = nums[0];
        for (int i = 1; i < nums.length; i++) {
            min = Math.min(min, nums[i]);
        }
        for (int i = 0; i < nums.length; i++) {
            ans += (nums[i] - min);
        }
        return ans;
    }
}
